package exercises.Charpter8;

import java.util.Random;

class Shape {
  public void draw() {}
  public void erase() {}
  public void test() {System.out.println("Shape.test()");}
}

class Circle extends Shape{
	@Override
	public void draw(){System.out.println("Circle.draw()");}
	@Override
	public void erase(){System.out.println("Circle.erase()");}
	@Override
	public void test(){System.out.println("Circle.test()");}
}

class Square extends Shape{
	@Override
	public void draw(){System.out.println("Square.draw()");}
	@Override
	public void erase(){System.out.println("Square.erase()");}
	@Override
	public void test(){System.out.println("Square.test()");}
}

class Triangle extends Shape{
	@Override
	public void draw(){System.out.println("Triangle.draw()");}
	@Override
	public void erase(){System.out.println("Triangle.erase()");}
	@Override
	public void test(){System.out.println("Triangle.test()");}
}

class RandomShapeGenerator{
	private Random rand = new Random(47);
	public Shape next(){
		switch (rand.nextInt(3)){
		default:
		case 0: return new Circle();
		case 1: return new Square();
		case 2: return new Triangle();
		}
	}
}

public class Two {
	private static RandomShapeGenerator gen = new RandomShapeGenerator();
	public static void main(String[] args){
		Shape[] s = new Shape[9];
		for (int i = 0; i < 9; i++){
			s[i] = gen.next();
			s[i].draw();
		}
	}
}
